﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using DTO;
using System.Web.Security;
namespace EC21_EDiamond
{
    public partial class ThemDonHang : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadCongTyVanChuyen();
            LoadHinhThucGiao();
            LoadKhachHang();
        }
        void LoadCongTyVanChuyen()
        {
            CongTyVanChuyenBUS  ctvcbus = new CongTyVanChuyenBUS();
            drpCongTyVanChuyen.DataSource = ctvcbus.LoadCongTyVanChuyen() ;
            drpCongTyVanChuyen.DataTextField = "TenCTVC";
            drpCongTyVanChuyen.DataValueField = "MaCTVC";
            drpCongTyVanChuyen.DataBind();
        }
        void LoadHinhThucGiao()
        {
            HinhThucGiaoBUS  htgbus = new HinhThucGiaoBUS();
            drpHinhThucGiao.DataSource = htgbus.LoadHinhThucGiao();
            drpHinhThucGiao.DataTextField = "TenHTG";
            drpHinhThucGiao.DataValueField = "MaHTG";
            drpHinhThucGiao.DataBind();
        }
        void LoadKhachHang()
        {
            KhachHangBUS  khbus = new KhachHangBUS();
            drpKhachHang.DataSource = khbus.LoadKhachHang();
            drpKhachHang.DataTextField = "TenKH";
            drpKhachHang.DataValueField = "MaKH";
            drpKhachHang.DataBind();
        }

        protected void btnDongY_Click(object sender, EventArgs e)
        {
            //DonHangBUS dhbus = new DonHangBUS (); 
            //DonHangDTO   donhang = new DonHangDTO();
            ////donhang.NgayLap   = CalendarNgayLap.;
            ////donhang.NgayGiao  =  CalendarNgayGiao.
            //donhang.TenKH = txtTenKhachHang.Text;
            //donhang.DiaChi=txtDiaChi.Text;
            //donhang.DienThoai = txtDienThoai.Text;
            //donhang.Email =txtDienThoai.Text;
            //donhang.TinhTrang=txtTinhTrang.Text;
            //donhang.TrangThai=txtTrangThai.Text;
            //donhang.TongTien = int.Parse(txtTongTien.Text);
            //donhang.MaCTVC = drpCongTyVanChuyen.SelectedIndex;
            //donhang.MaHTG =drpHinhThucGiao .SelectedIndex;
            //donhang.MaKH =drpKhachHang.SelectedIndex;
            //if (DonHangBUS.ThemDonHang(donhang) != 0)
            //{
            //        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Thêm Thành Công!');", true);
                   
            //}
            //else
            //{
            //    ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Thêm Thất Bại!');", true);
            //}
        }     
    }
}